﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BiffenService.Db;
using BiffenService.Model;

namespace BiffenService.Control
{
    public class MemberControl
    {
        private static IMemberDb memberDb = new MemberDb();

        /// <summary>
        /// Method to find a member from the database with a specific id
        /// </summary>
        /// <param name="memberId">int memberId the id of the member we want to find</param>
        /// <returns>Member member the member found in the database</returns>
        public static Member FindMemberById(int memberId)
        {
            return memberDb.FindMemberByIdFromDatabase(memberId);
        }

        /// <summary>
        /// Method that inserts a member into the database
        /// </summary>
        /// <param name="name">String name the name of the new member</param>
        /// <param name="phone">int phone the phone number of the new member</param>
        /// <param name="email">String email the email address of the new memeber</param>
        /// <param name="Address">String address the address of the new member</param>
        /// <param name="zipcode">int zipcode the zipcode the new member lifes in</param>
        /// <param name="newsletter">bool newsletter true if the new member wants to recieve a newsletter, false if not</param>
        public static int CreateMember(string name, int phone, string email, string Address, int zipcode, bool newsletter)
        {
            return memberDb.InsertMemberIntoDatabase(name, phone, email, Address, zipcode, newsletter);
        }

        /// <summary>
        /// Method that finds a Member by a phone number
        /// </summary>
        /// <param name="phone">int phone the members phone number</param>
        /// <returns>Member member the member found in the database</returns>
        public static Member FindMemberByPhone(int phone)
        {
            return memberDb.FindMemberByPhone(phone);
        }


        #region . Login .
        public static Login GetLoginByPhone(int phone)
        {
            return memberDb.GetLoginByPhone(phone);
        }

        #endregion
    }

}
